<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
	
	public function index()
	{
		$this->load->helper('url');
		$this->load->model('nav_model');
		$menu = $this->nav_model->get_nav('home');
		
		$this->load->model('db_model');
		$this->db_model->loadTable('post_type');
		$news_type = $this->db_model->find(array('name'=>'新闻'));
		
		$news = '';
		$new_type_id = '';
		if($news_type)
		{
			$new_type_id  = $news_type->id;
			$this->db_model->loadTable('post');
			$news = $this->db_model->findAll(array('typeid'=>$news_type->id), array('id', 'name'), 'order desc, id asc', 0, 5);
		}
		$config['view'] = 'home_view';
		$config['menu'] = $menu;
		$config['news'] = $news;
		$config['new_type_id'] = $new_type_id;
		
		
		
		$this->load->view('global_view', $config);		
	}
	
	private function test()
	{
		return  'hello world';		
	}
	
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */